<?php

class Dir {
    
    var $dp;
    
    function Dir ($name)
    {
        $this->dp = opendir($name);
    }
    
    function read ()
    {
        if ($this->dp)
        {
            return readdir($this->dp);
        }
    }
    
    function close()
    {
        if ($this->dp)
        {
            closedir($this->dp);
        }
    }
    
	function isEmpty()
	{
	    if ($dh = @opendir($dir))
	    {
	        while ($file = readdir($dh))
	        {
	            if ($file != '.' && $file != '..') {
	                closedir($dh);
	                return false;
	            }
	        }
	        closedir($dh);
	        return true;
	    }
	    else return false; // whatever the reason is : no such dir, not a dir, not readable
	}
        
}

?>